var API = "http://localhost:8080/";


// 2.请求拦截器
axios.interceptors.request.use(function (config) {
    let token = window.localStorage.getItem("token");//这里取token之前，你肯定需要先拿到token,存一下
    if (token) {//判断token是否为空
      config.headers.token = token; //如果要求携带在请求头中
    }
    return config;
}, function (error) {
    return error;
});

function arrayToTree(items) {
    const rootItems = [];
    const lookup = {};

    for (const item of items) {
        const itemId = item.id;
        lookup[itemId] = item;
        const parentId = item.parentid;
        if (parentId === null || parentId === "0" || parentId === 0) {
            rootItems.push(item);
        } else {
            const parent = lookup[parentId];
            if (parent) {
                if (!parent.children) {
                    parent.children = [];
                }
                parent.children.push(item);
            }
        }
    }

    return rootItems;
}